﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Drawing;

using DotSpatial.Data;

namespace FXnaGis
{

    /// <summary>
    /// 方便的显示一张位图
    /// </summary>
    public class FBitmapLayer:FLayer
    {

        public FBitmapLayer(string id,string fname,Extent ext):base(id)
        {


            this._extent = ext;

            this._image = Image.FromFile(fname);





 
        }


        Image _image;

        public Image Image
        {
            get { return _image; }
            set { _image = value; }
        }




        Extent _extent;



        public override DotSpatial.Data.Extent Extent
        {
            get
            {
                return this._extent;
            }
        }


        


        protected override void DoCollsionDectection(FXnaGis.FMapArgs args, System.Collections.Generic.List<DotSpatial.Data.Extent> regions)
        {
            base.DoCollsionDectection(args, regions);
        }

        protected override void DrawCore(FMapArgs args, List<Extent> regions)
        {

            foreach (Extent region in regions)
            {

                if (this._extent.Intersects(region))
                {

                    this.DrawImage(args);

                    return;


                }
            }

        }


        protected void DrawImage(FMapArgs args)
        {

            Rectangle rect = args.ProjToPixel(this._extent);

            args.Device.DrawImage(this._image, rect);


 
        }






    }
}
